import request from '@/utils/request'

/** 获取规则列表 GET /api/rule */
export async function rule(params, options) {
  console.log('query get rule', params, options)
  const res = await request('/u', {
    method: 'GET',
    params: { ...params },
    ...(options || {}),
  })
  return {
    data: res.data.records
  }
}

/** 修改规则 PUT /api/rule */
export async function updateRule(data, options) {
  //console.log('query put rule', data, options)
  return request('/u', {
    data: {
      ...data,
      updateTime: new Date().getTime()
    },
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(data, options) {
  console.log('query add rule', data, options)
  return request('/u', {
    data: {
      ...data,
      createTime: new Date().getTime()
    },
    method: 'POST',
    ...(options || {}),
  });
}
/** 删除规则 DELETE /api/rule */

export async function removeRule(data, options) {
  console.log('query del rule', data, options)
  return request('/u', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}
